home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / smailsrc.zip / SMAIL.ZIP / CONFIG.C < prev    next >
Text File  |  1990-05-05  |  1KB  |  50 lines

  1. /*
  2.  *      config.c: Read the configuration files for smail/PC
  3.  *
  4.  *      Stephen C. Trier
  5.  *      March 26, 1990
  6.  *
  7.  *      This file was written entirely by Stephen C. Trier
  8.  *      and is in the public domain.
  9.  */
  10.  
  11. /*
  12.  *      This is where the UUPC dependencies come out of the woodwork.
  13.  */
  14.  
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <stdlib.h>
  18. #include "config.h"
  19.  
  20. #define RCVAR(A)    ((A == 0) ? "UUPCSYSRC" : "UUPCUSRRC")
  21.  
  22. void ms_config(struct table_entry table[])
  23. {
  24.     char line[81];
  25.     char *rcfile;
  26.     FILE *fp;
  27.     int i, j;
  28.  
  29.     for (i = 0; i < 2; i++)  {
  30.     rcfile = getenv(RCVAR(i));
  31.     if (rcfile == NULL)  {
  32.         fprintf(stderr, "smail: $%s must be defined.\n", RCVAR(i));
  33.         exit(5);
  34.         }
  35.     fp = fopen(rcfile, "r");
  36.     while (!feof(fp))  {
  37.         fgets(line, 80, fp);
  38.         *strchr(line, '\n') = '\0';  /* Chop off the newline */
  39.         for (j = 0; table[j].n != NULL; j++) /* Check each table entry */
  40.         /* If the keyword for this table entry matches this line, */
  41.         if (strnicmp(line, table[j].n, strlen(table[j].n)) == 0)  {
  42.             /* Copy its value into the proper variable. */
  43.             *(table[j].v) = strdup(line + strlen(table[j].n) + 1);
  44.         }
  45.         }
  46.     fclose(fp);
  47.     }
  48. }
  49.  
  50.